
/**
 *机场保障车辆
 * Created by Administrator on 2018/4/28.
 */

define(function (require,exports,module) {
    var sTpl = require("./airSecurityVehicle.html");
    require("./airSecurityVehicle.css");

    var VueComponent = Vue.extend({
        template: sTpl
        ,methods:{
            findAllASV:function() {
                var $this = this;
                axios.get(basepath+"/api/airSecurityVehicle/findAllASV"
                ).then(function (response) {
                    $this.tableData=response.data;
                });
            },

            addASV:function() {
                this.tl='添加保障车辆'
                this.addVehicleForm={
                    vehicleType:'',
                    vehicleName:'',
                    vehicleNum:'',
                    vehicleState:''};
                this.$refs.baseTable.dialogFormVisible = true;
                this.title='添加成功';

            },
            clear:function(){
                this.$refs.baseTable.dialogFormVisible = false;
            },
            saveASV:function () {
                var $this = this;
                this.$refs.addVehicleForm.validate(function(validate){
                    if(validate){
                        axios.post(basepath+'/api/airSecurityVehicle/saveASV',$this.addVehicleForm
                        )
                            .then(function (response) {
                                $this.checkASV();
                                $this.$notify({
                                    title: $this.title,
                                    message: $this.title
                                });
                                $this.$refs.baseTable.dialogFormVisible = false;
                            });
                    }
                });

            },
            editASV:function (scope) {
                this.tl='修改'
                this.$refs.baseTable.dialogFormVisible = true;
                this.addVehicleForm=JSON.parse(JSON.stringify(scope.row));
                this.title='修改成功';
            },
            checkASV:function () {

                var $this = this;
                axios.get(basepath+"/api/airSecurityVehicle/checkASV",{
                    params: {
                        vehicleType:$this.checkFormInline.vehicleType,
                        vehicleState:$this.checkFormInline.vehicleState
                    }}
                ).then(function (response) {
                    console.log(response);
                    $this.tableData=response.data;
                });
            },
            delectASV:function(scope){
                var $this = this ;
                this.$confirm('确定删除？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'success'
                }).then(function() {
                    axios.post(basepath+'/api/airSecurityVehicle/delectASV',scope.row)
                        .then(function (response) {
                            $this.$notify({
                                title: '已删除',
                                message: '已删除'
                            });

                            $this.checkASV();
                        });
                })

            }
        },
        mounted:function() {

        }
        ,data:function(){
            return {
                vehicleTypes:[{
                    value:'行李传送车',
                    label:'行李传送车'
                },{
                    value:'牵引车',
                    label:'牵引车'
                },
                    {
                        value:'清水车',
                        label:'清水车'
                    },
                    {
                        value:'食品车',
                        label:'食品车'
                    },
                    {
                        value:'排污车',
                        label:'排污车'
                    },
                    {
                        value:'加油车',
                        label:'排污车'
                    },

                ],
                tl:'',
                title:'',
                dialogFormVisible: false,
                checkFormInline: {
                    vehicleType:'',
                    vehicleState:''
                },
                addVehicleForm: {
                    vehicleType:'',
                    vehicleName:'',
                    vehicleNum:'',
                    vehicleState:''
                },
                tableData: {}
            }
        },
        created:function (){
            this.findAllASV();

        },
        activated:function () {
            messages.$emit('change','保障车辆');
        }
    });
    module.exports = VueComponent;
})
